from multiprocessing import Process,Queue
import time,random
def concumer(q,name):
    while True:
        product=q.get()
        if product:
            print(f'{name}用了{product}')
        else:break
def producer(q,name,goods):
    for i in range(10):
        goods_i=f'{goods}{i}'
        print(f'{name}生产了{goods_i}')
        time.sleep(random.random())
        q.put(goods_i)


if __name__ == '__main__':
    q=Queue()
    c1=Process(target=concumer,args=(q,'alex'))
    p1 = Process(target=producer, args=(q,'AK','AK47'))
    p2=Process(target=producer,args=(q,'M4','M4A1'))
    c1.start()
    p1.start()
    p2.start()
    p1.join()
    p2.join()
    q.put(None)













